package vertx;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.net.NetServer;
import io.vertx.core.net.NetServerOptions;
import netty.util.TimeDelay;

public class PushServerNode extends AbstractVerticle {

    TimeDelay timeDelay = TimeDelay.getInstance();

    @Override
    public void start() throws Exception {
        NetServerOptions options = new NetServerOptions();
        options.setTcpNoDelay(true);

        NetServer server = vertx.createNetServer(options);

        server.connectHandler(socket -> {
            // Handle the connection in here
            socket.handler(buffer -> {
                socket.write(buffer.toString());
            });
        });

        server.listen(1235, "0.0.0.0", res -> {
            if (res.succeeded()) {
                System.out.println("Server is now listening!");
            } else {
                System.out.println("Failed to bind!");
            }
        });
    }

    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        vertx.deployVerticle(PushServerNode.class.getName());
    }

}
